import React, { Children, Component, createRef } from "react"
import PropTypes from 'prop-types';
const ChildComponent = (props) => {
    return (
        <div>
            12313123
            {props.children}
        </div>
    )
}
class App extends Component {
    constructor() {
        super()

        this.state = {
            name: 'React',
            subtitle: '123'
        }
        this.editSub = this.editSub.bind(this)
        console.log('constructor')
    }
    // 默认参数
    static defaultProps = {
        color: 'blue'
    };
    // 默认类型检验
    static propTypes = {
        color: PropTypes.string
    };
    // 方法
    testa() {
        this.setState({
            name: 'Vue'
        })
    }
    editSub() {
        console.log(this)
        this.setState({
            subtitle: '中国'
        })
    }

    render() {
        let { subtitle, truth, color } = this.props
        console.log('Render');

        return (
            <div>
                <h2>{this.props.title}</h2>
                <h3>{this.props.subtitle}</h3> <button onClick={this.editSub}>修改副标题</button>
                我是 {truth ? <span>真的</span> : <span>假的</span>}
                color: {this.props.color}
                <ChildComponent>
                    插槽内容
                </ChildComponent>
            </div>

        )
    }
}
export default App;